﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using YArchitech.LIB;
using YJKCopyModel.ColumnTransModel;
using YJKCopyModel.YJKRevitWndr;
using YJKCopyModel.Forms;
using YJKCopyModel.TransformWall;

namespace YJKCopyModel.CommonTrans
{
	internal class QuickModelMainResposeHandler : IResponseHanlder
	{
		public void AddEndTime(DateTime inputDataTime)
		{
			this.m_endTime = inputDataTime;
		}

		public void AddOneResponse(RevitModelRebuildResponse inputResponse)
		{
			this.m_lstResponse.Add(inputResponse);
		}

		public void AddStartTime(DateTime inputDataTime)
		{
			this.m_startTime = inputDataTime;
		}

		public void HanlderResponse()
		{
			Dictionary<Type, List<RevitModelRebuildResponse>> dictionary = (from item in this.m_lstResponse
			group item by item.UseRequest.GetType()).ToDictionary((IGrouping<Type, RevitModelRebuildResponse> item) => item.Key, (IGrouping<Type, RevitModelRebuildResponse> item) => item.ToList<RevitModelRebuildResponse>());
			int num = 0;
			int num2 = 0;
			int num3 = 0;
			Type typeFromHandle = typeof(WallRevitModelRequest);
			bool flag = dictionary.ContainsKey(typeFromHandle);
			if (flag)
			{
				num = dictionary[typeFromHandle].FindAll((RevitModelRebuildResponse item) => item.IfSucess).Count;
			}
			Type typeFromHandle2 = typeof(ColumnRevitRequest);
			bool flag2 = dictionary.ContainsKey(typeFromHandle2);
			if (flag2)
			{
				num2 = dictionary[typeFromHandle2].FindAll((RevitModelRebuildResponse item) => item.IfSucess).Count;
			}
			Type typeFromHandle3 = typeof(DoorAndWindowRevitModelRequest);
			bool flag3 = dictionary.ContainsKey(typeFromHandle3);
			if (flag3)
			{
				num3 = dictionary[typeFromHandle3].FindAll((RevitModelRebuildResponse item) => item.IfSucess).Count;
			}
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.Append("成功生成墙体实例");
			stringBuilder.Append(num.ToString());
			stringBuilder.Append("个\n");
			stringBuilder.Append("成功生成柱实例");
			stringBuilder.Append(num2.ToString());
			stringBuilder.Append("个\n");
			stringBuilder.Append("成功生成门窗实例");
			stringBuilder.Append(num3.ToString());
			stringBuilder.Append("个\n");
			stringBuilder.Append("时间：");
			stringBuilder.Append(((int)(this.m_endTime - this.m_startTime).TotalSeconds).ToString());
			stringBuilder.Append("秒");
			Process currentProcess = Process.GetCurrentProcess();
			IntPtr mainWindowHandle = currentProcess.MainWindowHandle;
			YJKWindowHandle owner = new YJKWindowHandle(mainWindowHandle);
			TransResultForm transResultForm = new TransResultForm(stringBuilder.ToString());
			transResultForm.ShowDialog(owner);
		}

		private DateTime m_startTime = default(DateTime);

		private DateTime m_endTime = default(DateTime);

		private List<RevitModelRebuildResponse> m_lstResponse = new List<RevitModelRebuildResponse>();
	}
}
